const ListenEventType = {
    PAUSE_MUSIC: 'PAUSE_MUSIC',      //音乐暂停
    PLAY_MUSIC: 'PLAY_MUSIC',        //音乐播放
    PLAY_EFFECT: 'PLAY_EFFECT',      //播放音效
    PAUSE_EFFECT: 'PAUSE_EFFECT',    //暂停音效
    INIT_CARD: 'INIT_CARD',          //初始化卡牌
    MODEL_DEAL_CAEDS: 'MODEL_DEAL_CAEDS',  //数据层发牌
    UI_DEAL_CARDS: 'UI_DEAL_CARDS',  //UI层发牌
    GET_GAMEPANEL_BY_VIEW: 'GET_GAMEPANEL_BY_VIEW',    //通过View获取节点
    GET_POPUPPANEL_BY_VIEW: 'GET_POPUPPANEL_BY_VIEW',    //通过View获取节点
    UI_OPEN_SENDAREA_CARD: 'UI_OPEN_SENDAREA_CARD',  //UI层翻开发牌区牌
    POST_MODEL_PLAYERNUM: 'POST_MODEL_PLAYERNUM',    //通知数据层玩家数目
    POST_CARD_COLOR: 'POST_CARD_COLOR',      //通知数据层卡牌颜色
    POST_UI_CARD_COLOR: 'POST_UI_CARD_COLOR',        //通知UI层卡牌颜色
    CLICK_CARD: 'CLICK_CARD',        //点击卡牌
    RECYCLE_CARD: 'RECYCLE_CARD',    //回收卡牌
    SELECT_CARD: 'SELECT_CARD',    //选择卡牌
    NEXT_PLAYER: 'NEXT_PLAYER',      //轮到下一位玩家出牌
    ANIMATION_OVER: 'ANIMATION_OVER',        //动画播放完毕
    POST_UI_ROBOT_DEAL_CARD: 'POST_UI_ROBOT_DEAL_CARD',      //通知UI层机器人发牌
    POST_UI_DEALAREA_TO_PLAYAREA: 'POST_UI_DEALAREA_TO_DRAPAREA',    //通知UI层将牌移至玩牌区
    POST_UI_NEXT_BAR: 'POST_UI_NEXT_BAR',            //通知UI层轮到玩家的bar处理
    POST_UI_SHOW_SELECTCOLOR: 'POST_UI_SHOW_SELECTCOLOR',    //通知UI层显示选择颜色面板
    POST_MODEL_SELECT_COLOR: 'POST_UI_SELECT_COLOR',     // 通知数据层修改颜色
    POST_MODEL_ISUNO: 'POST_MODEL_ISUNO',        //通知数据层是否UNO
    POST_UI_UNO: 'POST_UI_UNO',       //通知UI层UNO
    POST_UI_POINTS: 'POST_UI_POINTS',       //通知UI层玩家得分
    POST_UI_SUITABLE_CARDS: 'POST_UI_SUITABLE_CARDS',     //通知UI层玩家可出的牌
    RESTART_GAME: 'RESTART_GAME',    //重新开始一局
    INIT_AUDIO: 'INIT_AUDIO',         //初始化音效播放设置
    SHOW_GAMEOVER_PANEL: 'SHOW_GAMEOVER_PANEL',   //显示游戏结束面板
    GET_CARD_SPRITEFRAME_BY_TYPE: 'GET_CARD_SPRITEFRAME_BY_TYPE',        //获取对应的卡牌图片
    RETURN_CARD_SPRITEFRAME_BY_TYPE: 'RETURN_CARD_SPRITEFRAME_BY_TYPE',      //返回对应的卡牌图片
    POST_MODEL_ISGAMEOVER: 'POST_MODEL_ISGAMEOVER',           //询问数据层是否游戏结束
    POST_UI_ISGAMEOVER: 'POST_UI_ISGAMEOVER',             //通知UI层是否游戏结束

    NET_DATA: 'NET_DATA',   //网络数据
}

// 点击事件类型
const TouchEventType = {
    touchStart: cc.Node.EventType.TOUCH_START,
    touchMove: cc.Node.EventType.TOUCH_MOVE,
    touchEnd: cc.Node.EventType.TOUCH_END,
    touchCancel: cc.Node.EventType.TOUCH_CANCEL
}

// 面板类型
const PanelType = {
    STARTPANEL: 'startPanel',
    SELECTPANEL: 'selectPanel',
    GAMEPANEL: 'gamePanel',
    UICARD: 'UICard',
    POPUPPANEL: 'popupPanel',
    GAMEOVERPANEL: 'gameoverPanel'
}

// 卡牌的大小
const CardINF = {
    width: 116,//156,
    height: 159,//242
    intervalPixel: 2, // 卡牌之间的间隔
    marginPixel: 2, // 卡牌距离边界的距离
}

// 动画名称
const AnimationName = {
    all_Color: 'all_Color',
    blue_green: 'blue_green',
    change_clockwise: 'change_clockwise',
    draw_2: 'draw_2',
    draw_4: 'draw_4',
    green_red: 'green_red',
    red_yellow: 'red_yellow',
    stop_turn: 'stop_turn',
    yellow_blue: 'yellow_blue'
}

// 更改颜色动画对应的每一种颜色动画的持续时间，用来判断当前随机到的是哪种动画而对应的动画持续时间
const changeColorAni = [
    {
        name: AnimationName.blue_green,
        time: 0.5
    },
    {
        name: AnimationName.green_red,
        time: 0.4
    },
    {
        name: AnimationName.red_yellow,
        time: 0.3
    }, {
        name: AnimationName.yellow_blue,
        time: 0.5
    }
]

// 游戏说明文本
const explainContent = {
    normal: '普通牌由红、黄、蓝、绿4种颜色组成，每种颜色都拥有点数0-9的牌和三张特殊牌',
    add_2: '打出此牌后，下家将被罚摸2张牌并禁止出牌',
    ban: '打出“跳过”牌后，你的下家将停止出牌，轮到再下家出牌',
    turn: '打出“翻转”牌后，整个出牌顺序将翻转，如时针顺序变为逆时针顺序',
    change_color: '随机变更当前的出牌颜色',
    add_4: '打出此牌后，下家将罚摸4张并禁止出牌，而打出此牌的玩家更可指定出牌颜色',
    unoBtn: '当只剩下一张牌的玩家需要点击UNO按钮，否则会被罚牌两张'
}

// 玩家人数
enum playerPeople {
    twoP = 0,
    threeP = 1,
    fourP = 2
}

// 卡牌颜色
enum CardColor {
    red = 1,
    green = 2, //black
    blue = 3,  //flower
    yellow = 4, //rect
    special = 5     //特殊牌
}

// 卡牌类型
enum CardType {
    number = 0,
    ban = 1,
    turn = 2,
    add_2 = 3,
    changeColor = 4,
    add_4 = 5
}
//卡牌状态
enum CardStatus {
    CLOSE = 0,
    OPEN = 1
}

//当前轮到出牌的玩家
enum CurrentPlayer {
    Player1 = 0,
    Player2 = 1,
    Player3 = 2,
    Player4 = 3,
    Hole = 4,
}

// 卡牌所在的位置
enum CardLocation {
    sendCardArea = 0,   //发牌区
    mineCardArea = 1,      //1p玩牌区
    otherCardArea = 2,       //其他区域,包括收牌区,其他玩家玩牌区
    holeCardArea = 3,      //底牌区
}

// 音效类型
enum AudioType {
    card = 0,
    card_dealing = 1,
    change_color = 2,
    press_button = 3,
    snap = 4,
    game_over = 5,
    special_card = 6
}

// 弹出框类型
enum PopupType {
    selectColor = 0,        //颜色选择时
    selectRestart = 1,      //重新开始游戏
    info = 2,               //信息
    explain = 3             //游戏说明
}

//按钮类型,对应的颜色
enum BtnColor {
    green = 1,
    red,
    yellow,
    blue
}

// 解释文本类型
enum explainType {
    normal = 0,
    add_2 = 1,
    ban = 2,
    turn = 3,
    change_color = 4,
    add_4 = 5,
    unoBtn = 6
}

const CardNodeMap = new Map<string, number>([
    [`${CardColor.red}.2`, 34],
    [`${CardColor.red}.3`, 33],
    [`${CardColor.red}.4`, 31],
    [`${CardColor.red}.5`, 30],
    [`${CardColor.red}.6`, 29],
    [`${CardColor.red}.7`, 28],
    [`${CardColor.red}.8`, 27],
    [`${CardColor.red}.9`, 26],
    [`${CardColor.red}.10`, 25],
    [`${CardColor.red}.11`, 24],
    [`${CardColor.red}.12`, 23],
    [`${CardColor.red}.13`, 22],
    [`${CardColor.red}.14`, 35],

    [`${CardColor.green}.2`, 19],
    [`${CardColor.green}.3`, 18],
    [`${CardColor.green}.4`, 17],
    [`${CardColor.green}.5`, 16],
    [`${CardColor.green}.6`, 15],
    [`${CardColor.green}.7`, 14],
    [`${CardColor.green}.8`, 13],
    [`${CardColor.green}.9`, 12],
    [`${CardColor.green}.10`, 11],
    [`${CardColor.green}.11`, 9],
    [`${CardColor.green}.12`, 8],
    [`${CardColor.green}.13`, 7],
    [`${CardColor.green}.14`, 20],

    [`${CardColor.blue}.2`, 43],
    [`${CardColor.blue}.3`, 32],
    [`${CardColor.blue}.4`, 21],
    [`${CardColor.blue}.5`, 10],
    [`${CardColor.blue}.6`, 3],
    [`${CardColor.blue}.7`, 2],
    [`${CardColor.blue}.8`, 1],
    [`${CardColor.blue}.9`, 0],
    [`${CardColor.blue}.10`, 53],
    [`${CardColor.blue}.11`, 52],
    [`${CardColor.blue}.12`, 51],
    [`${CardColor.blue}.13`, 50],
    [`${CardColor.blue}.14`, 54],

    [`${CardColor.yellow}.2`, 48],
    [`${CardColor.yellow}.3`, 47],
    [`${CardColor.yellow}.4`, 46],
    [`${CardColor.yellow}.5`, 45],
    [`${CardColor.yellow}.6`, 44],
    [`${CardColor.yellow}.7`, 42],
    [`${CardColor.yellow}.8`, 41],
    [`${CardColor.yellow}.9`, 40],
    [`${CardColor.yellow}.10`, 39],
    [`${CardColor.yellow}.11`, 38],
    [`${CardColor.yellow}.12`, 37],
    [`${CardColor.yellow}.13`, 36],
    [`${CardColor.yellow}.14`, 49],

    [`${CardColor.red}.19`, 6],
    [`${CardColor.red}.18`, 5]
]);


export {
    ListenEventType,
    TouchEventType,
    PanelType,
    CardINF,
    AnimationName,
    changeColorAni,
    explainContent,
    playerPeople,
    CardColor,
    CardType,
    CardStatus,
    CurrentPlayer,
    CardLocation,
    AudioType,
    PopupType,
    BtnColor,
    explainType,
    CardNodeMap
}